package com.lancoo.cvas.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class SwaggerConfig {

    @Value("${lancoo.swagger-enable:false}")
    private Boolean enable;

    //配置Swagger的Bean实例
    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .enable(enable)
                .groupName("cvas")
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.lancoo.cvas"))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("标题：蓝鸽_中职排课V5.0.1_接口文档")
                .description("描述：用于中职版智能排课和选课")
                .version("版本号:5.0.1")
                .termsOfServiceUrl("http://www.chinalancoo.com/")
                .contact(new Contact("通用算法和智能排课项目组", null, null))
                .build();
    }



}